<template>
  <div class="app-container">
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          :loading="exportLoading"
          @click="handleDc('#exportNonPost', '来料入库单据')"
          v-hasPermi="['repertory:nonPostOrder:export']"
          >导出当前数据
        </el-button>
      </el-col>
      <el-col :span="2.2" style="position: absolute; right: 35px; top: 0">
        <Page
          style="margin-right: 0px"
          :current="queryParams.pageNum"
          :page-size="queryParams.pageSize"
          :total="total"
          @on-change="pageChange"
          simple
        ></Page>
      </el-col>
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table id="exportNonPost" v-loading="loading" :data="StorageList">
      <el-table-column label="单据类型" align="center" prop="idm_desc" />
      <el-table-column label="仓库" align="center" prop="v_ckdm">
        <template #default="scope">
          <dict-tag :options="allStorageOptions" :value="scope.row.v_ckdm" />
        </template>
      </el-table-column>
      <el-table-column label="开单未提交" align="center" prop="v_0cnt" />
      <el-table-column label="提交未审核" align="center" prop="v_1cnt" />
      <el-table-column label="审核未过账" align="center" prop="v_2cnt" />
      <el-table-column label="未过账总计" align="center" prop="v_allcnt" />
    </el-table>
  </div>
</template>

<script>
import { getAll, listStorage } from "@/api/repertory/Storage";
import { exportTable } from "@/utils/ruoyi";
import { getNonPostOrder } from "@/api/repertory/nonPostOrder";

export default {
  name: "NonPostOrder",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 选中数组
      ids: [],
      storageName: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 储位资料表格数据
      StorageList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 有效标识字典
      storageFlagOptions: [],

      //所以存储仓库
      allStorageOptions: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 20,
      },
    };
  },
  created() {
    getAll().then((response) => {
      this.allStorageOptions = response.data;
      for (let item of this.allStorageOptions) {
        item.dictLabel = item.storageName;
        item.listClass = "default";
        item.dictValue = item.storageId + "";
      }
    });
    this.getList();
  },
  methods: {
    /** 查询储位资料列表 */
    getList() {
      this.loading = true;
      getNonPostOrder(this.queryParams).then((response) => {
        this.StorageList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },

    pageChange(page) {
      this.queryParams.pageNum = page;
      this.getList();
    },

    handleDc(a, b) {
      exportTable(a, b);
    },
  },
};
</script>
